<template>
  <div>
    <van-nav-bar
      class="app-nav-bar"
      title="选择科室"
      left-arrow
      @click-left="$router.push('/')"
    />
    <van-search v-model="searchObj" placeholder="请输入医生姓名或科室名" />
    <div class="wrapper">
      <a href="javascript:;">
        <span>医院公告</span>
      </a>
      <a href="javascript:;">
        <span>医院介绍</span>
      </a>
      <a href="javascript:;">
        <span>预约规则</span>
      </a>
    </div>
    <van-tree-select
      height="593"
      :items="items"
      :active-id.sync="activeId"
      :main-active-index.sync="activeIndex"
      @click-item="clickItem"
    />
  </div>
</template>

<script>
import dictApi from '@/api/dict'
export default {
  name: "OrderIndex",
  data(){
    return{
      items:[],
      activeId: 1,
      activeIndex: 0,
      searchObj:''
    }
  },
  created() {
    this.init()
  },
  methods:{
    async init(){
      //获取科室列表
      await this.getDepList()
    },
    async getDepList(){
      const {data:res} = await  dictApi.dictList(86)
      this.items = res.data
    },
    clickItem(val){
      console.log(val)
      //跳转到医生列表页面
      this.$router.push({path:'/doctor',query:{depcode:val.value,depname:val.text}})
    }
  }
}
</script>

<style lang="less" scoped>
.wrapper{
  font-size: 13px;
  margin-left: 12px;
  a{
    display: inline-block;
    margin-right: 10px;
  }
}
</style>
